package com.gsd.activemq.spring;

import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Service;

/**
 * @author guoshoudu
 * @version 1.0
 * @description
 * @date 2021/6/29 5:23 下午
 */
@Service
public class SpringMQ_Consumer {
    @Autowired
    private JmsTemplate jmsTemplate;

    public static void main(String[] args) {
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        SpringMQ_Consumer consumer= (SpringMQ_Consumer) ctx.getBean("springMQ_Consumer");
        String receiveAndConvert = (String) consumer.jmsTemplate.receiveAndConvert();
        System.out.println("******消费者收到的消息："+receiveAndConvert);
    }
}
